<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>测试哦</title>
	<link rel="stylesheet" href="style.css">
	<script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
	<script src="echarts.js"></script>

</head>
<body>
	<!--<div id="main" style="width: 600px;height:400px;">
	</div>
	<script src="mian.js"></script>-->
	<div class="box" id="txt">
		<div class="input">
			<label>间隔时间</label>
			<input type="number" min="1" id="time"/>
		</div>
		<div class="input">
			<label>获取数量</label>
			<input type="number" min="1" id="num"/>
		</div>
		<div class="input">
			<button class="put">获取</button>
		</div>
	</div>
	<div class="box">
		<div class="input">
			<label>移动平均点</label>
			<input class="average" type="number" readonly />
		</div>
	</div>


<script>
    $('.put').click(function () {
		var num=$('#num').val();
		var time=$('#time').val()
		if(time){
			time=time+'min';
		}

        $.ajax({
            type: 'get',
            url: 'http://localhost:3000',
			data:{
				code:'g6',
				num:num,
				time:time
			},
            success: function (data) {
                let average=0;
				data.forEach(x=>{
					average+=x.close;
				})
				$('.average').val(average/39);
            },
            error: function (err) {
                console.log(err)
            }
        })
    })
</script>
<script type="text/javascript">

</script>
</body>
</html>